/*
 * BuilderAspect.cpp
 *
 *  Created on: Nov 3, 2008
 *      Author: Ryan
 */

#include "BuilderAspect.h"

#include <sstream>
#include "../Unit.h"

namespace OOInterface
{

BuilderAspect::BuilderAspect( const ConstUnitSet& set ):
	_buildableUnits( set )
{
}

BuilderAspect::~BuilderAspect()
{
}

bool BuilderAspect::canBuild( ConstUnitPtr building ) const
{
	for( ConstUnitSet::const_iterator it = _buildableUnits.begin(); it != _buildableUnits.end(); ++it )
		if( (*it)->getID() == building->getID() )
			return true;

	return false;
}

std::string BuilderAspect::toString() const
{
	std::ostringstream str;
	str << "Aspect: Builder Aspect";


	for( ConstUnitSet::const_iterator it = _buildableUnits.begin(); it != _buildableUnits.end(); ++it )
		str << "\t\tCan Build: " << (*it)->getName() << ":" << (*it)->getBuildTime() << "\n";


	return str.str();
}

}
